import request from '../utils/request'

// 用户登录

export const userLogin = ({ account, password }) => {
    return request.post('user/login', {
        account,
        password
    })
}

// 退出登录

export const userLogout = (token) => {
    return request.post('user/logout', {}, {
        headers: {
            token
        }
    })
}
// 修改密码

export const UpdatePass = (info, token) => {
    return request.post('user/updatePwd', info, {
        headers: {
            token
        }
    })
}

// 获取我的团队
export const UserInfo = (token) => {
    return request.get('user/info', {
        headers: {
            token
        }
    })
}

// 获取我的团队
export const UserTeam = (page = 1, token) => {
    return request.get('user/team', {
        params: {
            page_no: page,
            page_size: 8
        },
        headers: {
            token
        }
    })
}

// 添加购物车功能
export const CartAdd = (id, num, token,type) => {
    return request.post('cart/add', {
        goods_id: id,
        goods_num: num,
        type:type
    }, {
        headers: {
            token
        }
    })
}
// 获取购物车列表信息

export const UserCart = (page, token,type) => {
    return request.get('cart/lists', {
        params: {
            page_no: page,
            page_size: 10,
            type:type
        },
        headers: {
            token
        }
    })
}

export const UserCartList = (type,token) => {
    console.log(type);
    return request.get('cart/lists', {
        headers: {
            token
        },
        params: {
            page_no: 1,
            page_size: 1000,
            type:type
        },
    })
}



// 修改面
export const CartFace = (id, num,type, token) => {
    return request.post('cart/face', {
        cart_id: id,
        goods_num: num,
        type:type
    }, {
        headers: {
            token
        }
    })
}

export const CartCalc = (token) => {
    return request.get('cart/calc', {
        headers: {
            token
        }
    })
}

export const indexconfig = (token) => {
    return request.get('index/config', {
        headers: {
            token
        }
    })
}


export const CartTogo = (token) => {
    return request.get('cart/togo', {
        headers: {
            token
        }
    })
}
